import Vue from "vue";
import VueRouter, { RouteConfig } from "vue-router";
import { Component } from "vue-property-decorator";

Component.registerHooks([
	"beforeRouteEnter",
	"beforeRouteUpdate",
	"beforeRouteLeave"
]);
Vue.use(VueRouter);

const routes:RouteConfig[] = [
	{
		path: "/",
		name: "root",
		redirect: "/home/"
	},
	{
		path: "/home/",
		name: "home",
		component: () => import("../views/Home.vue")
	},
	{
		path: "/medicalData",
		name: "medicalRoot",
		component: () => import("../views/medicalData/index.vue"),
		children: [
			{
				path: "outpatient/",
				name: "outpatientData",
				component: () => import("../views/medicalData/outpatient.vue")
			},
			{
				path: "hospital/",
				name: "hospitalData",
				component: () => import("../views/medicalData/hospital.vue")
			},
			{
				path: "device/",
				name: "hospitalDevice",
				component: () => import("../views/medicalData/device.vue")
			},
			{
				path: "epidemic/",
				name: "epidemic",
				component: () => import("../views/medicalData/epidemic.vue")
			}
		]
	},
	{
		path: "/space/",
		name: "space",
		component: () => import("../views/space/spaceRoot.vue"),
		children: [
			{
				path: "main/",
				name: "spaceMain",
				component: () => import("../views/space/spaceMain.vue")
			}
		]
	},
	{
		path: "/smt/",
		name: "smt",
		component: () => import("../views/smt/smtRoot.vue"),
		children: [
			{
				path: "main/",
				name: "smtMain",
				component: () => import("../views/smt/smtMain.vue")
			}
		]
	},
	{
		path: "/device/",
		name: "device",
		component: () => import("../views/device/deviceRoot.vue"),
		children: [
			{
				path: "main/",
				name: "deviceMain",
				component: () => import("../views/device/deviceMain.vue")
			},
			{
				path: "elevator/",
				name: "elevator",
				component: () => import("../views/device/elevator.vue")
			}
		]
	},
	{
		path: "/repair/",
		name: "repair",
		component: () => import("../views/repair/repairRoot.vue"),
		children: [
			{
				path: "repair/",
				name: "repairTable",
				component: () => import("../views/repair/repair.vue")
			},
			{
				path: "maintenance/",
				name: "maintenanceTable",
				component: () => import("../views/repair/maintenance.vue")
			},
			{
				path: "maintenancePlan/",
				name: "maintenancePlan",
				component: () => import("../views/repair/maintenancePlan.vue")
			},
			{
				path: "requestAdd/",
				name: "requestAdd",
				component: () => import("../views/repair/addRequest.vue")
			},
			{
				path: "operation/:id/",
				name: "operation",
				component: () => import("../views/repair/operation.vue")
			},
			{
				path: "detail/:id/",
				name: "detail",
				component: () => import("../views/repair/operation.vue")
			}
		]
	},
	{
		name: "energy",
		path: "/energy/",
		component: () => import("../views/energy/energyRoot.vue"),
		children: [
			{
				name: "energyMain",
				path: "main/",
				component: () => import("../views/energy/energyCount.vue")
			}
		]
	}
];

const router = new VueRouter({
	mode: 'hash',
	base: process.env.NODE_ENV === "production" ? "/static/UnityWeb/desktop/dist/" : "/",
	routes
});

export default router;
